import { takeEvery, put } from 'redux-saga/effects';
import axios from 'axios';
import * as types from './actionTypes';
import * as creator from './actionCreators';

// generator function
function* mySaga() {
	yield takeEvery(types.GET_MY_LIST, getList);
}

function* getList() {
	// axios
	// 	.get('http://rap2api.taobao.org/app/mock/238757/getList')
	// 	.then((res) => {
	// 		// console.log(res);
	// 		const data = res.data;
	// 		const action = creator.getListAction(data);
	// 		dispatch(action);
	// 	});
	const res = yield axios.get('http://rap2api.taobao.org/app/mock/238757/getList');
	const action = creator.getListAction(res.data);
	yield put(action);
}

export default mySaga;
